package com.coolpad.job.device.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.hadoop.hbase.HbaseTemplate;

@Slf4j
//@Configuration
public class HBaseConfigurations {

    @Value("${spring.data.hbase.quorum}")
    private String zookeeperQuorum;

    @Value("${spring.data.zookeeper.property.clientPort}")
    private String clientPort;

    @Value("${spring.data.hbase.nodeParent}")
    private String ZNodeParent;

    @Value("${hbase.master}")
    private String HMaster;


    @Bean
    public org.apache.hadoop.conf.Configuration hadoopConfig() {
        org.apache.hadoop.conf.Configuration conf = new org.apache.hadoop.conf.Configuration();
        conf.set("hbase.zookeeper.quorum", zookeeperQuorum);
        conf.set("hbase.zookeeper.property.clientPort", clientPort);
        conf.set("zookeeper.znode.parent", ZNodeParent);
        conf.set("hbase.master", HMaster);
        conf.setInt("hbase.rpc.timeout",20000);
        conf.setInt("hbase.client.operation.timeout",30000);
        conf.setInt("hbase.client.scanner.timeout.period",200000);
        return conf;
    }

    @Bean
    public HbaseTemplate hbaseTemplate(org.apache.hadoop.conf.Configuration configuration) {
        return new HbaseTemplate(configuration);
    }


}
